package o2o.thridpost.dada.config;

import java.util.HashMap;
import java.util.Map;

/**
 * 获取所有的errorCode的map
 *
 * @author sunyufan deporation@qq.com
 * @date 2021/5/6 16:05
 * @description: ErrorCode 单例 获取所有的errorCode的map
 * https://newopen.imdada.cn/#/quickStart/develop/code?_k=wbykn5
 */
public class ErrorCode {
    private static ErrorCode instance;

    private static Map<Integer,String> errorCode;

    private ErrorCode(){
        errorCode = new HashMap<>();
        errorCode.put(-1,"系统异常");
        errorCode.put(999,"系统维护中,暂时不能发单");
        errorCode.put(1000,"网络异常,获取数据超时,请重试");
        errorCode.put(1993,"参数不能为空");
        errorCode.put(1994,"format值不正确,默认为json");
        errorCode.put(1995,"body值不能为null");
        errorCode.put(1996,"v的值不正确,默认为1.0");
        errorCode.put(1997,"原始订单order_id不能为空");
        errorCode.put(1998,"请求参数的个数不正确,请仔细核对");
        errorCode.put(1999,"接口请求的headers为application/json");
        errorCode.put(2000,"接口请求参数不能为空");
        errorCode.put(2001,"app_key无效");
        errorCode.put(2002,"没有绑定正式商户,请检查接口中source_id值");
        errorCode.put(2003,"签名错误");
        errorCode.put(2004,"无效的门店编号");
        errorCode.put(2005,"订单不存在,请核查订单号");
        errorCode.put(2006,"订单回调URL不存在");
        errorCode.put(2007,"参数query需按要求传值");
    }

    public static ErrorCode getInstance(){
        if (instance == null){
            synchronized (ErrorCode.class){
                instance = new ErrorCode();
            }
        }
        return instance;
    }

    public Map<Integer, String> getErrorCode() {
        Map<Integer, String> temp = new HashMap<>(errorCode);
        return temp;
    }
}
